//
//  DBArrayController.m
//  aPlanner
//
//  Created by Daniel Braun on 02/09/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "DBArrayController.h"


@implementation DBArrayController

- (id)newObject
{
	id res=[super newObject];
	if (!res) return res;
	//NSArray *a=[self exposedBindings];
	if (![res respondsToSelector:@selector(setOwner:)]) return res;

	NSDictionary *dic=[self infoForBinding:@"contentArray"];
	id mgr=[dic valueForKey:NSObservedObjectKey];
	NSString *str=[dic valueForKey:NSObservedKeyPathKey];
	if (!mgr) return res;
	if (!str) return res;
	id owner=nil;
	NSArray *a=[str componentsSeparatedByString:@"."];
	if ([a count]==1) owner=mgr;
	else if ([a count]<1) return res;
	else {
		NSMutableArray *b=[NSMutableArray arrayWithArray:a];
		[b removeLastObject];
		str=[b componentsJoinedByString:@"."];
		owner=[mgr valueForKeyPath:str];
	}
	[res setOwner:owner];
	
	return res;
}
@end
